package com.saicmotor.room.Dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.saicmotor.room.Entity.User;

import java.util.List;

/**
 * @Author xinxinzhang
 * @Date 2022/08/17
 **/
@Dao
public interface UserDao {

    //增
    //可以设置当新增冲突的时候处理的方法
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(User... users);

    //删
    @Delete
    void delete(User... users);

    //改
    @Update
    void update(User... users);

    //查
    // 查询多个时可以配合LiveData和RxJava 2
    @Query("SELECT * FROM user")
    List<User> getAllUsers();
}
